package com.bazhua.bazo.controller;

import com.bazhua.bazo.common.utils.JwtUtil;
import com.bazhua.bazo.repository.model.result.CommonResult;
import com.bazhua.bazo.service.IAgentRecordService;
import com.bazhua.bazo.service.IAgentUserService;
import com.bazhua.bazo.service.ICheckUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: starmile
 * @Description:
 * @Create: 2021-01-25 23:25
 **/
@Api(tags = "代理商业务员")
@RestController
@RequestMapping("/api/agentUser")
public class AgentUserController {

    @Autowired
    private IAgentUserService agentUserService;

    @ApiOperation(value = "page", notes = "代理商业务员分页")
    @RequestMapping(value = "/page", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public CommonResult page(Integer pageNum, Integer pageSize, @RequestHeader String token) {
        Long userId = JwtUtil.getUserIdByToken(token);
        return agentUserService.getPage(pageNum, pageSize, userId);
    }

    @ApiOperation(value = "", notes = "删除代理商业务员")
    @RequestMapping(value = "/", method = RequestMethod.DELETE, produces = "application/json")
    @ResponseBody
    public CommonResult delete(Long id, @RequestHeader String token) {
        Long userId = JwtUtil.getUserIdByToken(token);
        return agentUserService.deleteAgentUser(id);
    }
}
